
local assets=
{

    Asset("ANIM", "anim/yuemiheng_equipment.zip"), 
	Asset("IMAGE", "images/yuemiheng_hat.tex"), 
	Asset("ATLAS", "images/yuemiheng_hat.xml"),
}

local prefabs =
{
}
local function onequiphat(inst, owner) 
    owner.AnimState:OverrideSymbol("swap_hat", "yuemiheng_equipment", "000000")
    owner.AnimState:OverrideSymbol("hair", "yuemiheng_equipment", "00000000")
    owner.AnimState:OverrideSymbol("hair_hat", "yuemiheng_equipment", "0000000")

 
    owner.AnimState:Show("HAT")
    owner.AnimState:Show("HAT_HAIR")

        
    if owner:HasTag("player") then 
            owner.AnimState:Hide("HEAD")
            owner.AnimState:Show("HEAD_HAT")
        end
        if inst.components.fueled ~= nil then
            inst.components.fueled:StartConsuming()
        end
end

local function onunequiphat(inst, owner) 
    owner.AnimState:ClearOverrideSymbol("swap_hat", "yuemiheng_equipment", "000000")
    owner.AnimState:ClearOverrideSymbol("hair", "yuemiheng_equipment", "00000000")
    owner.AnimState:ClearOverrideSymbol("hair_hat", "yuemiheng_equipment", "0000000")
    owner.AnimState:Hide("HAT")
    owner.AnimState:Hide("HAT_HAIR")

    
        if owner:HasTag("player") then
            owner.AnimState:Show("HEAD")
            owner.AnimState:Hide("HEAD_HAT")
        end

        if inst.components.fueled ~= nil then
            inst.components.fueled:StopConsuming()
        end
end


local function fn(Sim)
	local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("yuemiheng_hat") 
    inst.AnimState:SetBuild("virtuosa_equipment")
    inst.AnimState:PlayAnimation("idle",true)

	inst:AddTag("hat")
	inst:AddTag("hide")
    	
    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end
	
    inst:AddComponent("inspectable")
		
    inst:AddComponent("inventoryitem") 
	inst.components.inventoryitem.atlasname = "images/yuemiheng_hat.xml"
       
	inst:AddComponent("equippable") 
	inst.components.equippable.equipslot = EQUIPSLOTS.HEAD 
	inst.components.equippable:SetOnEquip( onequiphat ) 
    inst.components.equippable:SetOnUnequip( onunequiphat ) 
    
	MakeHauntableLaunchAndPerish(inst)
    return inst
end 
    
return Prefab( "yuemiheng_hat", fn, assets, prefabs) 